/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.WS;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import oracle.jdbc.driver.OracleDriver;

/**
 *
 * @author Trabajo
 */
@WebService()
public class IngresoInformacion {

    /**
     * Web service operation
     */
    @WebMethod(operationName = "ingresarInformacion")
    public String ingresarInformacion(@WebParam(name = "latitud")
    final double latitud, @WebParam(name = "longitud")
    final double longitud, @WebParam(name = "tipoInseguridad")
    final double tipoInseguridad, @WebParam(name = "descripcion")
    final String descripcion)
    {
        try
        {
            DriverManager.registerDriver(new OracleDriver());
            Connection conexion =  DriverManager.getConnection("jdbc:oracle:thin:@chie.uniandes.edu.co:1522:chie10", "s3702a09", "a3702a09");
            PreparedStatement statement = conexion.prepareStatement("insert into robosregistrados values (secrobosregistrados.nextval, ?, ?, ?, ?)");
            statement.setFloat(1, Float.parseFloat(latitud + ""));
            statement.setFloat(2, Float.parseFloat(longitud + ""));
            statement.setString(3, descripcion);;
            statement.setFloat(4, Float.parseFloat(tipoInseguridad + ""));
            statement.execute();
            statement.close();
            conexion.close();
            return "EXITO";
        }
        catch (SQLException ex)
        {
            return "Excepcion:" + ex.getMessage();
        }
    }

}
